package com.example.demo.pojo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private static final String SUCCESS = "1";
    private static final String ERROR = "0";

    private String code;
    private Object data;
    private String msg;

    //成功无参
    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS);
        return result;
    }

    //成功有参
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setData(data);
        return result;
    }
    //失败
    public static Result error(String msg){
        Result result = new Result();
        result.setCode(ERROR);
        result.setData(msg);
        return result;
    }



}
